{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="{% static 'layui/css/layui.css' %}" rel="stylesheet">
    <link href="{% static 'css/main.css' %}" rel="stylesheet">
</head>
<body id="index">
<div id="nav-placeholder">
    <nav style="width: 220px;height: 100%;color: #fff; background-color: RGBA(33,37,41,var(--bs-bg-opacity,1))!important">
        <div class="logo">
            <div class="logo-image">
                <img src="{% static 'images/logo.gif' %}"/>
            </div>
            <div class="logo-title"></div>
        </div>
        <ul class="layui-nav layui-nav-tree" lay-filter="test" style="width: 220px">
            {% if "首页" in user.menuList %}
            <li class="layui-nav-item menu-item layui-this" data-page="home"><a href="/home/?userId={{user.userId}}">销售数据</a></li>
            {% endif %}
            {% if "用户管理" in user.menuList %}
            <li class="layui-nav-item menu-item" data-page="users"><a href="/users/?userId={{user.userId}}">用户管理</a>
            </li>
            {% endif %}
            {% if "后台管理" in user.menuList %}
            <li class="layui-nav-item menu-item" data-page="role"><a href="/admin/?userId={{user.userId}}" target="_blank">后台管理</a>
            </li>
            {% endif %}
            <li class="layui-nav-item menu-item" data-page="center"><a
                    href="/center/?userId={{user.userId}}">用户中心</a></li>
            <li class="layui-nav-item menu-item" data-page="fx"><a
                    href="/fx/?userId={{user.userId}}">数据分析</a></li>
        </ul>
    </nav>
</div>
<div class="content" style="padding: 0">
    <div id="header-placeholder" style="background-color: #fff;">
        <div class="header-menu">
            <div style=" padding: 10px">
                <i class="layui-icon layui-icon-home" style="margin-right: 10px"></i> 首页
            </div>
            <div class="user-info" style="display: flex;align-items: center">
                <dvi id="userinfo">
                    {{ user.userName }}
                    <i class="layui-icon layui-icon-down layui-font-12"></i>
                    <div id="drop-menu" style="display: none">
                        <ul>
                            <li><a href="/login/">退出登录</a></li>
                            <li><a href="/center/?userId={{user.userId}}">个人中心</a></li>
                        </ul>
                    </div>
                </dvi>
            </div>
        </div>
        <div class="header-tab" style="border-top: 1px solid #dedede">
            <div class="breadcrumb" style="padding: 10px">
        <span class="layui-breadcrumb" lay-separator="|">
          <a href="/home/?userId={{user.userId}}&pageSize=100&page={{ data.shopPage }}"><i class="layui-icon layui-icon-return" style="margin-right: 10px"></i>BACK</a>
          <a><cite>销售数据</cite></a>
        </span>
            </div>
        </div>
    </div>
    <div id="main-placeholder" style="background-color: #fff;margin-top: 10px;padding: 10px">
        <div id="userApp">
            <div class="user-page">
                <table style="">
                    <thead>
                    <tr>
                        <th lay-data="{field:'num', width:100, fixed: 'left',  title: 'ID'}">序号</th>
                         <th lay-data="{field:'shop', width:100}">店铺</th>
                        <th lay-data="{field:'model', width:100}">型号</th>
                        <th lay-data="{field:'price', width:100}">价格</th>
                        <th lay-data="{field:'size', width:100}">尺码</th>
                        <th lay-data="{field:'sales', width:100}">销量</th>
                        <th lay-data="{field:'evaluate', width:100}">评价数量</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for shop_data in data.dataList %}
                    <tr>
                        <td>{{ shop_data.num }}</td>
                        <td>{{ shop_data.shop }}</td>
                        <td>{{ shop_data.model }}</td>
                        <td>{{ shop_data.price }}</td>
                        <td>{{ shop_data.size }}</td>
                        <td>{{ shop_data.sales }}</td>
                        <td>{{ shop_data.evaluate }}</td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
<!--                <div id="pagenation"></div>-->
            </div>
        </div>
    </div>
    <div id="footer-placeholder"></div>
</div>

</body>
<script src="{% static 'js/jquery-3.7.1.min.js' %}"></script>
<script src="{% static 'js/echarts.min.js' %}"></script>
<script src="{% static 'layui/layui.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>


<script>
  function onDelete(rowId){
    layer.confirm('确认删除此用户？', {
      btn: ['删除', '取消'] //可以无限个按钮
    }, function(index, layero){
      location.href='/userDel/?userId={{ user.userId }}&ID='+rowId;
    }, function(index){
      //按钮【按钮二】的回调
    });
  }


  let existMenu = localStorage.getItem('menus');
  let existMenus = existMenu ? JSON.parse(existMenu): [];
  let currentPage = 'home';
  let href = location.href.split('/')
  if(href.length >= 4){
    currentPage = href[4];
    currentPage = currentPage.slice(0,-5)
    console.log(currentPage)
  }

  let page = location.search.replace('?page=', '')
  layui.use('laypage', function(){
    var laypage = layui.laypage;
    laypage.render({
      elem: 'pagenation',
      curr: {{ data.page }},
      limit: 100,
      count: {{ data.totalNum }}, //数据总数，从服务端得到
      jump: function(obj, first){
        console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
        console.log(obj.limit); //得到每页显示的条数
        //首次不执行
        if(!first){
          location.href="/home/?userId={{ user.userId }}&pageSize=100&page="+obj.curr
        }
      }
    });
  });

</script>
</html>